/**
 * 
 */
package com.douyu.ocean.recom.platfrom.core.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.douyu.ocean.recom.platform.api.model.entiry.RecomPos;
import com.douyu.ocean.recom.platform.api.model.entiry.RecomRule;
import com.douyu.ocean.recom.platfrom.core.dal.mapper.RecomPosMapper;
import com.douyu.ocean.recom.platfrom.core.service.RecomPosService;

import tk.mybatis.mapper.entity.Example;

/**
 * @author leiruiqi
 *
 */
@Service("recomPosService")
public class RecomPosServiceImpl implements RecomPosService{

	@Resource
	private RecomPosMapper  recomPosMapper;
	
	@Override
	public void save(RecomPos recomPos) {
		recomPosMapper.insertSelective(recomPos);
	}

	@Override
	public List<RecomPos> queryAllByStatus(Integer status) {
		Example condition = new Example(RecomPos.class);
		condition.orderBy("id").asc();
		condition.createCriteria().andEqualTo("status", 0);
		return recomPosMapper.selectByExample(condition);
	}

	@Override
	public boolean updateById(RecomPos record) {
		return 1==recomPosMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public RecomPos getByCode(String code) {
		RecomPos record = new RecomPos();
		record.setCode(code);
		return recomPosMapper.selectOne(record);
	}

	@Override
	public RecomPos getById(Long id) {
		RecomPos record = new RecomPos();
		record.setId(id);
		return recomPosMapper.selectOne(record);
	}

}
